﻿using System;
using uTrade.Core;

namespace uTrade.Data
{
    public class StockSecurityBar
    {
        /// <summary>
        ///
        /// </summary>
        public int id { get; set; }

        /// <summary>
        ///
        /// </summary>
        public string Symbol { get; set; }

        /// <summary>
        ///
        /// </summary>
        public DateTime? Time { get; set; }

        /// <summary>
        /// 开盘价
        /// </summary>
        public decimal? Open { get; set; }

        /// <summary>
        /// 收盘价
        /// </summary>
        public decimal? Close { get; set; }

        /// <summary>
        /// 最高价
        /// </summary>
        public decimal? High { get; set; }

        /// <summary>
        /// 最低价
        /// </summary>
        public decimal? Low { get; set; }

        /// <summary>
        /// 成交量
        /// </summary>
        public decimal? Volume { get; set; }

        /// <summary>
        /// 成交额
        /// </summary>
        public string Turnover { get; set; }

        /// <summary>
        ///
        /// </summary>
        public string UpNum { get; set; }

        /// <summary>
        ///
        /// </summary>
        public string DownNum { get; set; }

        public Bar ToBar()
        {
            Bar bar = new Bar
            {
                DateTime = (DateTime)this.Time,// DateTime.ParseExact(n._id, "yyyyMMdd", null),
                Open = (double)this.Open,
                High = (double)this.High,
                Low = (double)this.Low,
                Close = (double)this.Close,
                Volume = (double)this.Volume,
            };
            DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
            //bar.TradingDay = ((DateTime)this.Time - startTime).TotalSeconds;

            return bar;
        }
    }
}